package com.example.projetandroid_lacroix_pizant;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class connectionUser extends Activity implements OnClickListener{

	private Button loginButton;
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.connection_user);
        
        //on recupere le bouton de connection
        loginButton = (Button) findViewById(R.id.button2);
        //on ajoute un evenement
        loginButton.setOnClickListener(this);
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
    public void onClick(View v){
   	
    	if(v.getId() == R.id.button2){
    		//recuperation du login
    		final EditText mail = (EditText) findViewById(R.id.editText1);
    		String mailUser = mail.getText().toString();		
    		
    		//recuperation du mot de passe
    		final EditText password = (EditText) findViewById(R.id.editText2);
    		String mdpUser = password.getText().toString();
    		
    		boolean valideForm = true;
    		
    		//validation du formulaire
    		if(mail.length() == 0){
    			Toast.makeText(this, "Email requis", Toast.LENGTH_SHORT).show();
    			valideForm = false;
    		}
    		if(password.length() == 0){
    			Toast.makeText(this, "Mot de passe requis", Toast.LENGTH_SHORT).show();
    			valideForm = false;
    		}

    		//si tous les champs sont remplis
    		if(valideForm){
    			//on s'oriente vers la page de profil du user
    			Intent intent = new Intent(connectionUser.this, profilUser.class);
    			startActivity(intent);
    		}
    	
    		
    		
    	}

    }
}
